package com.baicaoyuan.web.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

/**
 * 是否为合作商户
 */
@RequiredArgsConstructor
@Getter
public enum ProjectBusinessEnum {

    /**
     * 合作商户
     */
    COOPERATIVE("2"),

    /**
     * 普通平台
     */
    PLATFORM("1");

    private final String status;

    /**
     * 根据标识获取枚举
     *
     * @param category
     * @return
     */
    public static ProjectBusinessEnum acquire(final String category) {
        Optional<ProjectBusinessEnum> categoryEnum = Arrays.stream(ProjectBusinessEnum.values())
                .filter(c -> (Objects.equals(c.status, category)))
                .findFirst();
        return categoryEnum.orElse(ProjectBusinessEnum.PLATFORM);
    }
}
